const { defineConfig } = require("@vue/cli-service");
const { name } = require("./package");

module.exports = defineConfig({
  transpileDependencies: true,
  // vue.config.js关闭eslint校验
  lintOnSave: false,
  devServer: {
    port: 8082, // 子应用端口
    headers: {
      "Access-Control-Allow-Origin": "*", // 允许跨域
    },
    proxy: {
      "/api": {
        target: "https://pcapi-xiaotuxian-front-devtest.itheima.net",
        changeOrigin: true,
        pathRewrite: {
          "^/api": "",
        },
      },
      "/weather": {
        target: "http://wthrcdn.etouch.cn",
        changeOrigin: true,
        pathRewrite: {
          "^/weather": "",
        },
      },
      "/weather2": {
        target: "https://api.oioweb.cn",
        changeOrigin: true,
        pathRewrite: {
          "^/weather2": "",
        },
      },
    },
  },
  configureWebpack: {
    output: {
      library: `${name}-[name]`,
      libraryTarget: "umd", // 把微应用打包成 umd 库格式
      chunkLoadingGlobal: `webpackJsonp_${name}`, // webpack5 配置项
    },
  },
});
